//
//  PAUserInfo.m
//  PAMobileWallet
//
//  Created by Gavin Zhang on 7/14/13.
//  Copyright (c) 2013 平安付. All rights reserved.
//

#import "PAUserInfo.h"

@implementation PAUserInfo

@synthesize account             = _account;
@synthesize phoneNum            = _phoneNum;
@synthesize realName            = _realName;
@synthesize headImageUrl        = _headImageUrl;
@synthesize accountType         = _accountType;
@synthesize accountStatus       = _accountStatus;
@synthesize headImageDigest     = _headImageDigest;

- (id)initWithDic:(NSDictionary *)dic
{
    self = [super init];
    if (self) {
        if ([dic objectForKey:k_account]) self.account = [dic objectForKey:k_account];
        if ([dic objectForKey:k_phoneNum]) self.phoneNum = [dic objectForKey:k_phoneNum];
        if ([dic objectForKey:k_realName]) self.realName = [dic objectForKey:k_realName];
        if ([dic objectForKey:k_headImageUrl]) self.headImageUrl = [dic objectForKey:k_headImageUrl];
        if ([dic objectForKey:k_accountType]) self.accountType = [[dic objectForKey:k_accountType] integerValue];
        if ([dic objectForKey:k_accountStatus]) self.accountStatus = [[dic objectForKey:k_accountStatus] integerValue];
        if ([dic objectForKey:k_headImageDigest]) self.headImageDigest = [dic objectForKey:k_headImageDigest];
    }
    return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder
{
    [aCoder encodeObject:_account forKey:k_account];
    [aCoder encodeObject:_phoneNum forKey:k_phoneNum];
    [aCoder encodeObject:_realName forKey:k_realName];
    [aCoder encodeObject:_headImageUrl forKey:k_headImageUrl];
    [aCoder encodeInteger:_accountType forKey:k_accountType];
    [aCoder encodeInteger:_accountStatus forKey:k_accountStatus];
    [aCoder encodeObject:_headImageDigest forKey:k_headImageDigest];
}

- (id)initWithCoder:(NSCoder *)aDecoder{
    self = [super init];
    if (self) {
        _account = [aDecoder decodeObjectForKey:k_account];
        _phoneNum = [aDecoder decodeObjectForKey:k_phoneNum];
        _realName = [aDecoder decodeObjectForKey:k_realName];
        _headImageUrl = [aDecoder decodeObjectForKey:k_headImageUrl];
        _accountType = [aDecoder decodeIntegerForKey:k_accountType];
        _accountStatus = [aDecoder decodeIntegerForKey:k_accountStatus];
        _headImageDigest = [aDecoder decodeObjectForKey:k_headImageDigest];
    }
    return self;
}

@end
